<template>
    <template v-for="item in menuData">
        <el-sub-menu :key="item.path" v-if="item.children && item.children.length > 0" :index="item.path">
            <template #title>
                <el-icon>
                    <i class="iconfont text-[20px]" :class="item.icon"></i>
                </el-icon>
                <span>{{ item.title }}</span>
            </template>
            <comp-sub-menu :menuData="item.children"></comp-sub-menu>
        </el-sub-menu>
        <el-menu-item
            :key="item.id"
            v-else
            :index="item.path"
            :disabled="item.disabled"
        >
            <el-icon>
                <i class="iconfont text-[20px]" :class="item.icon"></i>
            </el-icon>
            <template #title>
                <span>{{ item.title }}</span>
            </template>
        </el-menu-item>
    </template>
</template>

<script setup>
import CompSubMenu from "./CompSubMenu.vue";
import {computed} from "vue";
import {useRouter} from "vue-router";

const props = defineProps({
    menuData: {
        type: Array,
        default: [],
    },
});

const curRoute = computed(() => {
    const router = useRouter();
    const {path} = router.currentRoute.value;
    return path;
});
</script>